﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TagCloudSoma;
using System.Threading;
using System.Globalization;

namespace Main
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                TagCloud T = new TagCloud();
                String source = T.GetSource(textBox1.Text);
                label2.Text = T.stripHTMLTag(source);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text != "")
            {
                TagCloud T = new TagCloud();
                label2.Text = T.cleaner(textBox2.Text);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            label2.Text = "";
            textBox1.Text = "";
            textBox2.Text = "";
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (label2.Text != "")
            {
                TagCloud T = new TagCloud();
                Dictionary<string, int> t = new Dictionary<string, int>();
                t = T.wordCounter(label2.Text, 10); ;

                string cadena = "";
                foreach (KeyValuePair<string, int> kvp in t)
                {
                    //Console.WriteLine("{0}: {1}", word, list[word]);
                    cadena += kvp.Key;
                    cadena += ": ";
                    cadena += kvp.Value;
                    cadena += "\n";
                }

                label2.Text = cadena;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("es-ES");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES");

            textBox1.Text = "http://somabarcelona.com/Company.aspx?op=comp";
            textBox2.Text = "to BE or not to be!";
        }


    }
}
